/*package game.entries.ghosts;



import game.controllers.GhostController;
import game.core.Game;
import game.entries.Util;

/*
 * This is the class you need to modify for your entry. In particular, you need to
 * fill in the getActions() method. Any additional classes you write should either
 * be placed in this package or sub-packages (e.g., game.entries.ghosts.mypackage).
 */
/*
public class FunGhosts implements GhostController
{
	
	//Place your game logic here to play the game as the ghosts
	public int[] getActions(final Game game,long timeDue)
	{
		//determines whether the ghost is within ten of pacman
		class CloseToPacMan extends Decision {
			int ghostNum;
			public CloseToPacMan(Node yes_branch, Node no_branch, int ghostNum) {
				super(yes_branch, no_branch);
				this.ghostNum = ghostNum;
			}
				//...
			public boolean decide() {
				int target;
				target  = game.getCurGhostLoc(ghostNum);
				if(game.getPathDistance(game.getCurPacManLoc() , target) < 10){
					return true;
				}			
				return false;
			}
		}
		
		// Checks if pacman has eaten a blue power pill
		class BluePillEaten extends Decision{
			int ghostNum;
			public BluePillEaten(Node yes_branch, Node no_branch, int ghostNum){
				super(yes_branch, no_branch);
				this.ghostNum = ghostNum;
			}
			public boolean decide(){
				if(game.isEdible(ghostNum))
					return true;
				return false;
			}
		}
		
		//Checks if pacman is close to a power pill
		class PacManCloseToBluePill extends Decision{
			public PacManCloseToBluePill(Node yes_branch, Node no_branch){
				super(yes_branch, no_branch);
			}
			public boolean decide(){
				int pacLoc = game.getCurPacManLoc();
				int[] pillLoc = game.getPowerPillIndices();
				for(int i = 0; i < pillLoc.length; i++){
					if(game.getPathDistance(pacLoc, pillLoc[i]) < 30){
						return true;
					}
				}
				return false;
			}
		}

		// Ghost chases pacman on a shortest intercept course
		class ChasePacMan extends Action {
			int ghostNum;
			public ChasePacMan(int ghostNum) {
				this.ghostNum = ghostNum;
			}
			public int perform() {
				int target = game.getNextGhostDir(ghostNum, game.getCurPacManLoc(), true, Game.DM.PATH);
				
				return target;
			}
		}
		
		// Ghosts run away when pack man has eaten the blue power pill
		class GhostRunAway extends Action{
			int ghostNum;
			public GhostRunAway(int ghostNum){
				this.ghostNum = ghostNum;
			}
			public int perform(){
				int target = game.getNextGhostDir(ghostNum, game.getCurPacManLoc(), false, Game.DM.PATH);
				return target;
			}
		}
		
		// Actions that the ghosts will take when they are more than ten feet away. One keeps chase while the others try to hem pacman in.
		class GetThePacMan extends Action{
			int ghostNum;
			public GetThePacMan(int ghostNum){
				this.ghostNum = ghostNum;
			}
			public int perform(){
				int target = 0;
				// first ghost chases pacman always
				if (ghostNum == 0){
					target = game.getNextGhostDir(ghostNum, game.getCurPacManLoc(), true, Game.DM.PATH);
				}
				// second ghost aims for one of the two junctions nearest pacman
				else if(ghostNum ==1){
					int [] junctions = Util.nearestJunctions(game, game.getCurPacManLoc());
					//GameView.addPoints(game,Color.RED,junctions[0]);
					target = junctions[2];
					target = game.getNextGhostDir(ghostNum, target, true, Game.DM.PATH);
				}
				// third ghost aims for the third of the two junctions nearest pacman
				else if(ghostNum == 2){
					int [] junctions = Util.nearestJunctions(game, game.getCurPacManLoc());
					//GameView.addPoints(game, Color.BLUE, junctions[1]);
					target = junctions[3];
					target = game.getNextGhostDir(ghostNum, target, true, Game.DM.PATH);
				}
				// fourth ghost randomly chooses for either the fourth square in front or behind pacman
				else if(ghostNum == 3){
					target = getFourthSquare(game);
					//GameView.addPoints(game, Color.YELLOW, target); - breaks the game for some reason
					target = game.getNextGhostDir(ghostNum, target, true, Game.DM.PATH);

				}
				return target;
			}
		}
		
		//Each ghost makes use of a single decision tree
		// first ghost AI decision tree
		
		Action firstChasePacMan = new ChasePacMan(0);
		Action firstGetThePacMan = new GetThePacMan(0);
		Decision firstCloseToPacMan = new CloseToPacMan (firstChasePacMan, firstGetThePacMan, 0);
		Action firstGhostRunAway = new GhostRunAway(0);
		Decision firstPacManCloseToBluePill = new PacManCloseToBluePill(firstChasePacMan, firstCloseToPacMan);
		Decision firstBluePillEaten = new BluePillEaten (firstGhostRunAway, firstPacManCloseToBluePill, 0);
		
		Action firstGhost = firstBluePillEaten.makeDecision();

		//second ghost AI decision tree
		
		Action secondChasePacMan = new ChasePacMan(1);
		Action secondGetThePacMan = new GetThePacMan(1);
		Decision secondCloseToPacMan = new CloseToPacMan (secondChasePacMan, secondGetThePacMan, 1);
		Action secondGhostRunAway = new GhostRunAway(1);
		Decision secondPacManCloseToBluePill = new PacManCloseToBluePill(secondGhostRunAway, secondCloseToPacMan);
		Decision secondBluePillEaten = new BluePillEaten (secondGhostRunAway, secondPacManCloseToBluePill, 1);
		
		Action secondGhost = secondBluePillEaten.makeDecision();
		
		// third ghost AI decision tree
		
		Action thirdChasePacMan = new ChasePacMan(2);
		Action thirdGetThePacMan = new GetThePacMan(2);
		Decision thirdCloseToPacMan = new CloseToPacMan (thirdChasePacMan, thirdGetThePacMan, 2);
		Action thirdGhostRunAway = new GhostRunAway(2);
		Decision thirdPacManCloseToBluePill = new PacManCloseToBluePill(thirdGhostRunAway, thirdCloseToPacMan);
		Decision thirdBluePillEaten = new BluePillEaten (thirdGhostRunAway, thirdPacManCloseToBluePill, 2);
		
		Action thirdGhost = thirdBluePillEaten.makeDecision();
		
		// fourth ghost AI decision tree
		
		Action fourthChasePacMan = new ChasePacMan(3);
		Action fourthGetThePacMan = new GetThePacMan(3);
		Decision fourthCloseToPacMan = new CloseToPacMan (fourthChasePacMan, fourthGetThePacMan, 3);
		Action fourthGhostRunAway = new GhostRunAway(3);
		Decision fourthPacManCloseToBluePill = new PacManCloseToBluePill(fourthGhostRunAway, fourthCloseToPacMan);
		Decision fourthBluePillEaten = new BluePillEaten (fourthGhostRunAway, fourthPacManCloseToBluePill, 3);
		
		Action fourthGhost = fourthBluePillEaten.makeDecision();

		// setting the directions that the ghost shall take as well as invoking my decision tree.
		int[] directions=new int[Game.NUM_GHOSTS];
		directions[0] = firstGhost.perform();
		directions[1] = secondGhost.perform();
		directions[2] = thirdGhost.perform();
		directions[3] = fourthGhost.perform();
		return directions;
	}
	
	int getFourthSquare(Game game){
		int pacLoc = game.getCurPacManLoc();
		int pacDir = game.getCurPacManDir();
		int result = pacLoc;
		for(int i = 0; i<4; i++){
			int neighbor = game.getNeighbour(result, pacDir);
			if(neighbor != -1)
				result = neighbor;
			else
				break;
		}
		return result;
	}
	
}*/
